package com.jugheadzhou.server01.controller;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

/**
 * @author jugheadzhou
 * @date 2021-10-01
 */
@Data
@Slf4j
@RestController
@RequestMapping("test/")
public class TestController {

    @Value("${spring.application.name}")
    private String applicationName;

    @Value("${server.port}")
    private String port;

    /**
     * 测试服务
     *
     * @return
     */
    @GetMapping("info/{name}")
    public ResponseEntity<?> testSave(@PathVariable("name") String name) throws InterruptedException {
        log.info("开始调用测试接口：{}", name);

//        log.info("计算 1/0={}", 1/0);
//        TimeUnit.SECONDS.sleep(8);
        log.info("调用测试接口结束：{}", name);
        return ResponseEntity.ok("你好 +" + name + "，我是" + applicationName + ":" + port);
    }


}
